<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>学生选课-全部已发布课程</title>
    <link rel="stylesheet" href="../res/jiangtao/lib/mdl/material.indigo-pink.min.css">
    <link rel="stylesheet" href="../res/jiangtao/lib/mdl/icon.css">
    <script src="../res/js/jquery-3.0.0.min.js"></script>
    <script src="../res/js/materialize.min.js"></script>
    <script  src="../res/jiangtao/lib/mdl/material.min.js"></script>
</head>
<body>


<table align="center" class="mdl-data-table mdl-js-data-table mdl-shadow--2dp">
    <thead>
    <tr>
        <th class="mdl-data-table__cell--non-numeric" data-field="crs_id">教师编号</th>
        <th data-field="tid">教师姓名 </th>
        <th data-field="tname">院系编号</th>
        <th data-field="depid">院系名称</th>
        <th data-field="cid">课程编号</th>
        <th data-field="cname">课程名称</th>
        <th data-field="ctype">课程类型</th>
        <th data-field="cpre">课程课时</th>
        <th data-field="ccre">课程学分</th>
        <th data-field="cterm">课程学期</th>
        <th data-field="mod">修改发布信息</th>
        <th data-field="del">删除发布信息</th>
    </tr>
    </thead>

    <tbody>


    </tbody>
</table>

<dialog name="dialog" class="mdl-dialog--full-width">
    <h2 class="mdl-dialog__title">修改已发布课程信息</h2>
    <div class="mdl-dialog__content">
        <ul class="demo-list-item mdl-list">
            <li class="mdl-list__item">
                <span class="mdl-list__item-primary-content">
                   教师编号:<div id="tidmin"></div>
                </span>
            </li>
            <li class="mdl-list__item">
                <span class="mdl-list__item-primary-content">
                   教师姓名:<div id="tnamemin"></div>
                </span>
            </li>
            <li class="mdl-list__item">
                <span class="mdl-list__item-primary-content">
                   院系编号:<div id="depidmin"></div>
                </span>
            </li>
            <li class="mdl-list__item">
                <span class="mdl-list__item-primary-content">
                   院系名称:<div id="depnamemin"></div>
                </span>
            </li>
            <li class="mdl-list__item">
                <span class="mdl-list__item-primary-content">
                   课程编号:<div id="cidmin"></div>
                </span>
            </li>
            <li class="mdl-list__item">
                <span class="mdl-list__item-primary-content">
                   课程名称:<div id="cnamemin"></div>
                </span>
            </li>
            <li class="mdl-list__item">
                <span class="mdl-list__item-primary-content">
                   课程类型:<!-- Numeric Textfield -->
                      <div id="coursetype" class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
                        <input class="mdl-textfield__input" type="text" pattern="-?[0-9]*(\.[0-9]+)?" id="otype">
                        <label class="mdl-textfield__label" for="otype">0 选修,1 必修</label>
                        <span class="mdl-textfield__error">Input is not a number!</span>
                      </div>
                </span>
            </li>
            <li class="mdl-list__item">
                <span class="mdl-list__item-primary-content">
                   课程课时:<!-- Numeric Textfield -->
                      <div id="preriods" class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
                        <input class="mdl-textfield__input" type="text" pattern="-?[0-9]*(\.[0-9]+)?" id="opre">
                        <label class="mdl-textfield__label" for="opre">课时</label>
                        <span class="mdl-textfield__error">Input is not a number!</span>
                      </div>
                </span>
            </li>
            <li class="mdl-list__item">
                <span class="mdl-list__item-primary-content">
                   课程学分:<!-- Numeric Textfield -->
                      <div id="credit" class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
                        <input class="mdl-textfield__input" type="text" pattern="-?[0-9]*(\.[0-9]+)?" id="ocre">
                        <label class="mdl-textfield__label" for="ocre">学分</label>
                        <span class="mdl-textfield__error">Input is not a number!</span>
                      </div>
                </span>
            </li>
            <li class="mdl-list__item">
                <span class="mdl-list__item-primary-content">
                   课程学期:<!-- Numeric Textfield -->
                      <div id="term" class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
                        <input class="mdl-textfield__input" type="text" pattern="-?[0-9]*(\.[0-9]+)?" id="oterm">
                        <label class="mdl-textfield__label" for="oterm">学期(1-8)</label>
                        <span class="mdl-textfield__error">Input is not a number!</span>
                      </div>
                </span>
            </li>
        </ul>
    </div>

    <div class="mdl-dialog__actions">
        <button type="button" class="mdl-button ok">确定</button>
        <button type="button" class="mdl-button close">取消</button>
    </div>
</dialog>
<input type="hidden" name="hcid" id="hcid"/>
<script type="text/javascript">
//    var tidmin=sessionStorage.tchid
//    var tnamemin=sessionStorage.tchname
//    var tdepid=sessionStorage.tdpm
//    var tdepname=sessionStorage.dep
//    $.ajax({
//        type:"post",
//        url:"allCS",
//        success:function(data){
//            var tb="";
//            for(var index in data){
//                tb+="<tr>";
//                tb+="<td class='mdl-data-table__cell--non-numeric'>"
//                    +data[index].tchId
//                    +"</td>"
//                tb+="<td>"
//                    +data[index].teacherByTchId.name
//                    +"</td>"
//                tb+="<td>"
//                    +data[index].dpmId
//                    +"</td>"
//                tb+="<td>"
//                    +data[index].departmentByDpmId.dpmName
//                    +"</td>"
//                tb+="<td>"
//                    +data[index].crsId
//                    +"</td>"
//                tb+="<td>"
//                    +data[index].courseByCrsId.crsName
//                    +"</td>"
//                tb+="<td>"
//                    +data[index].type
//                    +"</td>"
//                tb+="<td>"
//                    +data[index].preriods
//                    +"</td>"
//                tb+="<td>"
//                    +data[index].credit
//                    +"</td>"
//                tb+="<td>"
//                    +data[index].term
//                    +"</td>"
//
//                if (tidmin==data[index].tchId){
//                    tb+="<td>"
//                        +"<input type='button' class='mdl-button mdl-js-button mdl-button--raised' value='修改课程信息' onclick='modclass("+data[index].crsId+","+ '"' +data[index].courseByCrsId.crsName+ '"' +")'/>"
//                        +"</td>"
//                    tb+="<td>"
//                        +"<input type='button' class='mdl-button mdl-js-button mdl-button--raised' value='删除考试信息' onclick='delclass("+data[index].crsId+")'/>"
//                        +"</td>"
//                }else {
//                    tb+="<td>"
//                        +"<input type='button' class='mdl-button mdl-js-button mdl-button--raised' disabled value='无权修改'/>"
//                        +"</td>"
//                    tb+="<td>"
//                        +"<input type='button'class='mdl-button mdl-js-button mdl-button--raised' disabled value='无权删除'/>"
//                        +"</td>"
//                }
//                tb+="</tr>"
//            }
//            $("tbody").html(tb);
//        }
//    })
//
//    function modclass(classid,claname) {
//        document.getElementById("tidmin").innerHTML=tidmin
//        document.getElementById("cidmin").innerHTML=classid
//        document.getElementById("cnamemin").innerHTML=claname
//        document.getElementById("tnamemin").innerHTML=tnamemin
//        document.getElementById("depidmin").innerHTML=tdepid
//        document.getElementById("depnamemin").innerHTML=tdepname
//
//        var dialog = document.querySelector('dialog')
//        dialog.showModal();
//        if (! dialog.showModal) {
//            dialogPolyfill.registerDialog(dialog);
//        }
//        dialog.querySelector('.ok').addEventListener('click', function() {
//            var odpmid=tdepid
//            var ocrsid=classid
//            var otchid=tidmin
//            var otype=$("#otype").val()
//            var opre=$("#opre").val()
//            var ocre=$("#ocre").val()
//            var oterm=$("#oterm").val()
//
//            $.ajax({
//                type:"post",
//                url:"modcs",
//                data:{
//                    "courseSchedule.dpmId":odpmid,
//                    "courseSchedule.crsId":ocrsid,
//                    "courseSchedule.tchId":otchid,
//                    "courseSchedule.type":otype,
//                    "courseSchedule.preriods":opre,
//                    "courseSchedule.credit":ocre,
//                    "courseSchedule.term":oterm,
//                },
//                success:function(data){
//                    alert("修改成功")
//                    parent.location.reload()
//                    //window.location.href="http://localhost:8080/ssmis/teacher/main.html"
//                }
//            })
//        });
//        dialog.querySelector('.close').addEventListener('click', function() {
//            dialog.close();
//        });
//    }
//
//    function delclass(csid) {
//        $.ajax({
//            type:"post",
//            url:"delcs",
//            data: {
//                "courseSchedule.dpmId": tdepid,
//                "courseSchedule.crsId": csid,
//                "courseSchedule.tchId": tidmin,
//            },
//            success:function() {
//               alert("删除成功")
//                parent.location.reload()
//            }
//            })
//
//    }

</script>
</body>
</html>